const AndroidSdk = {
  /**
   *  @desc 写日志
   *  @param str 日志内容
   * **/
  writeLog: (str) => {
    try {
      window.native.handleMessage(
        JSON.stringify({
          action: 'WebLogAction',
          callback: '',
          data: str
        })
      );
    } catch (e) {
      console.warn(e.message);
    }
  },
  /**
   * @desc 设备信息
   * **/
  deviceInfoAction() {
    try {
      const obj = {
        action: 'SelfServiceQueryAction',
        callback: 'getDeviceInfoCallBack',
        data: ''
      };
      window.native.handleMessage(JSON.stringify(obj));
    } catch (e) {
      console.warn(e.message);
    }
  },
  ImageAction(url) {
    try {
      window.native.handleMessage(
        JSON.stringify({
          action: 'ImageAction',
          callback: null,
          data: url
        })
      );
    } catch (e) {
      console.warn(e.message);
    }
  },
  /**
   * @desc 获取设备信息
   * **/
  PlayVideoAction(jsonstr) {
    try {
      window.native.handleMessage(
        JSON.stringify({
          action: 'PlayVideoAction',
          callback: 'closeVideo',
          data: jsonstr
        })
      );
    } catch (e) {
      console.warn(e.message);
    }
  }
};

export default AndroidSdk;
